local daofu = fk.CreateSkill{
    name = "ym2__daofu",
    tags = {Skill.Permanent,Skill.Compulsory},
}
Fk:loadTranslationTable{
    ["ym2__daofu"] = "蹈复",
    [":ym2__daofu"] = "持恒技，锁定技，当你受到伤害后，伤害来源须令其攻击范围内的一名女性角色交换主副将，否则，你弃置你与其各三张牌。",
    ["#ym2__daofu-choose"] = "蹈复：令攻击范围内的一名女性角色交换主副将，否则 %dest 将弃置你三张牌",
}
daofu:addEffect(fk.Damaged,{
    anim_type = "masochism",
    can_trigger = function (self, event, target, player, data)
        return player == target and player:hasSkill(daofu.name) and data.from and data.from:isAlive()
    end,
    on_cost = function (self, event, target, player, data)
        local room = player.room
        local targets = table.filter(room:getAlivePlayers(),function (cp)
            return cp:isFemale() and data.from:inMyAttackRange(cp) and cp.deputyGeneral ~= ""
        end)
        local tos = player.room:askToChoosePlayers(data.from,{
            targets = targets,
            max_num = 1,
            min_num = 1,
            skill_name = daofu.name,
            prompt = "#ym2__daofu-choose::"..player.id
        })
        if #tos > 0 then
            event:setCostData(self,tos)
        else
            event:setCostData(self,{})
        end
        return true
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local tos = event:getCostData(self)
        if #tos > 0 then
            for _, cp in ipairs(tos) do
                local general = cp.general ~= "" and cp.general or "blank_shibing"
                local deputyGeneral = cp.deputyGeneral ~= "" and cp.deputyGeneral or "blank_shibing"
                room:prepareGeneral(cp,deputyGeneral,general,true)
            end
        else
            room:askToDiscard(player, {
                min_num = 3,
                max_num = 3,
                include_equip = true,
                skill_name = daofu.name,
                cancelable = false,
            })
            if not data.from:isNude() and data.from:isAlive() then
                local ids = data.from:getCardIds("he")
                if #ids > 3 then
                    ids = room:askToChooseCards(player, {
                        target = data.from,
                        flag = "he",
                        skill_name = daofu.name,
                        max = 3,
                        min = 3,
                    })
                end
                room:throwCard(ids, daofu.name, data.from, player)
            end
        end
    end,
})
return daofu